/**
 * @file packset.h
 * @author MaxwellWang
 * @brief 
 * @version v1.0.0
 * @date 2025/11/25
 * @copyright Copyright (c) 2025
 * this file is part of the mw-iap firmware
*/

#ifndef PACKSET_H_
#define PACKSET_H_

#include <stdint.h>
#include <stdbool.h>

//settings
#ifndef PACKET_MAX_PL_LEN
#define PACKET_MAX_PL_LEN   512
#endif

#define PACKET_BUFFER_LEN   (PACKET_MAX_PL_LEN + 8)

typedef struct
{
    void(*send_func)(unsigned char *data,unsigned int len);
    void(*process_func)(unsigned char *data,unsigned int len);
    unsigned int rx_read_ptr;
    unsigned int rx_write_ptr;
    int bytes_left;
    unsigned char rx_buffer[PACKET_BUFFER_LEN];
    unsigned char tx_buffer[PACKET_BUFFER_LEN];
}packset_state_t;

void Descramble(uint8_t *data,int32_t in_len);
void decodeCWRXpacket(uint8_t *data,int32_t in_len);



#endif



